package com.cs.springcloud.controller;


import com.cs.springcloud.entities.Dept;
import com.cs.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * DeptController
 *
 * @author zzc
 * @version 1.00
 * @Date 2019/3/17-22:06
 */
@RestController
public class DeptController {

    @Autowired
    DeptService deptService;
//    @Autowired
//    DiscoveryClient client;

    @GetMapping(value = "/haha")
    public Object discover(){
//        List<String> list = client.getServices();
//        System.out.println("==========="+list);

        return "hahaahah";
    }
    @RequestMapping(value = "/dept/add", method = RequestMethod.POST)
    public boolean add(@RequestBody Dept dept)
    {
        return deptService.addDept(dept);
    }

    @RequestMapping(value = "/dept/get/{id}", method = RequestMethod.GET)
    public Dept get(@PathVariable("id") Long id)
    {
        return deptService.findById(id);
    }

    @RequestMapping(value = "/dept/list", method = RequestMethod.GET)
    public List<Dept> list()
    {
        return deptService.findAll();
    }
}
